package com.tbit.uqbike.object.pojo.dto;

import com.tbit.uqbike.manager.exception.BaseException;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 区域共享配置绑定
 *
 * @Author:BUGTian
 * @DATE: 2023/1/5
 */
@Data
public class CardAccountBoundDTO {
    /**
     * 主键id
     */
    private Long id;
    /**
     * 互通区域id ,分割
     */
    private String accountIds;

    /**
     * 获取区域id List
     *
     * @return
     */
    public List<Integer> getAccountIdList() {
        List<Integer> accountIdList = new ArrayList<>();
        if (!StringUtils.hasText(accountIds)) {
            return accountIdList;
        }
        try {
            String[] accountIds = this.accountIds.split(",");
            for (String accountId : accountIds) {
                accountIdList.add(Integer.parseInt(accountId));
            }
        } catch (Exception e) {
            throw new BaseException("区域id有误");
        }

        return accountIdList;
    }


}
